package behavior.mediator;

import behavior.mediator.impl.HouseMediator;
import behavior.mediator.impl.HouseOwner;
import behavior.mediator.impl.Tenant;

public class MediatorTest {

	public static void main(String[] args) {
		/**
		 * 房屋买卖过程的总结
		 */
		HouseMediator mediator = new HouseMediator();

		// 房主和租房者只需要知道中介机构即可
		HouseOwner houseOwner = new HouseOwner("张三", mediator);
		Tenant tenant = new Tenant("李四", mediator);

		// 中介结构要知道房主和租房者
		mediator.setHouseOwner(houseOwner);
		mediator.setTenant(tenant);

		System.out.println(tenant.constact("听说你那里有三室的房子出租....."));
		System.out.println(houseOwner.constact("是的!请问你需要租吗?"));

		/**
		 * 聊天室方式的中介
		 */
		User robert = new User("Robert");
		User john = new User("John");

		robert.sendMessage("Hi! John!");
		john.sendMessage("Hello! Robert!");
	}

}
